<?php 

//Connection statement
require_once('Connections/cn.php');

// Load the common classes
require_once('includes/common/KT_common.php');

// Load the tNG classes
require_once('includes/tng/tNG.inc.php');

// Load the KT_back class
require_once('includes/nxt/KT_back.php');

// Make a transaction dispatcher instance
$tNGs = new tNG_dispatcher("");

// Start trigger
$formValidation = new tNG_FormValidation();
$formValidation->addField("des_actividad", true, "text", "", "", "", "Ingrese el tipo de actividad.");
$tNGs->prepareValidation($formValidation);
// End trigger

// begin Recordset
$query_rsActividad = "SELECT id_actividad, des_actividad FROM actividad";
$rsActividad = $cn->SelectLimit($query_rsActividad) or die($cn->ErrorMsg());
$totalRows_rsActividad = $rsActividad->RecordCount();
// end Recordset

// Make an insert transaction instance
$ins_actividad = new tNG_multipleInsert($cn);
$tNGs->addTransaction($ins_actividad);
// Register triggers
$ins_actividad->registerTrigger("STARTER", "Trigger_Default_Starter", 1, "POST", "KT_Insert1");
$ins_actividad->registerTrigger("BEFORE", "Trigger_Default_FormValidation", 10, $formValidation);
$ins_actividad->registerTrigger("END", "Trigger_Default_Redirect", 99, "includes/nxt/back.php");
// Add columns
$ins_actividad->setTable("actividad");
$ins_actividad->addColumn("des_actividad", "STRING_TYPE", "POST", "des_actividad");
$ins_actividad->setPrimaryKey("id_actividad", "NUMERIC_TYPE");

// Make an update transaction instance
$upd_actividad = new tNG_multipleUpdate($cn);
$tNGs->addTransaction($upd_actividad);
// Register triggers
$upd_actividad->registerTrigger("STARTER", "Trigger_Default_Starter", 1, "POST", "KT_Update1");
$upd_actividad->registerTrigger("BEFORE", "Trigger_Default_FormValidation", 10, $formValidation);
$upd_actividad->registerTrigger("END", "Trigger_Default_Redirect", 99, "includes/nxt/back.php");
// Add columns
$upd_actividad->setTable("actividad");
$upd_actividad->addColumn("des_actividad", "STRING_TYPE", "POST", "des_actividad");
$upd_actividad->setPrimaryKey("id_actividad", "NUMERIC_TYPE", "GET", "id_actividad");

// Make an instance of the transaction object
$del_actividad = new tNG_multipleDelete($cn);
$tNGs->addTransaction($del_actividad);
// Register triggers
$del_actividad->registerTrigger("STARTER", "Trigger_Default_Starter", 1, "POST", "KT_Delete1");
$del_actividad->registerTrigger("END", "Trigger_Default_Redirect", 99, "includes/nxt/back.php");
// Add columns
$del_actividad->setTable("actividad");
$del_actividad->setPrimaryKey("id_actividad", "NUMERIC_TYPE", "GET", "id_actividad");

// Execute all the registered transactions
$tNGs->executeTransactions();

// Get the transaction recordset
$rsactividad = $tNGs->getRecordset("actividad");
$totalRows_rsactividad = $rsactividad->RecordCount();

function cargar($vista){
	global $tNGs, $formValidation, $ins_actividad, 
	$upd_actividad, $del_actividad, $rsactividad;
	require_once($vista);
}
?>